package com.example.campuslink.commen.adpter

import android.util.Log
import android.view.View
import android.widget.ImageView
import com.bumptech.glide.Glide
import com.example.campuslink.BR
import com.example.campuslink.R
import com.example.campuslink.commen.core.CoreAdapter
import com.example.campuslink.commen.core.CoreViewHolder
import com.example.campuslink.databinding.AdapterPublicPhotoBinding
import com.example.campuslink.viewModel.PublicViewModel

class PublicPhotoAdapter(vm: PublicViewModel) :
    CoreAdapter<AdapterPublicPhotoBinding, PublicViewModel, String>(
        BR.data,
        BR.viewModel,
        vm
    ) {
    override fun getItemLayoutId(viewType: Int): Int {
        return R.layout.adapter_public_photo
    }

    override fun onBindViewHolder(holder: CoreViewHolder, position: Int) {
        super.onBindViewHolder(holder, position)
        Glide.with(holder.itemView.context).load(mListData[position])
            .error(R.drawable.ic_empty)
            .into(holder.binding.root.findViewById<ImageView>(R.id.iv_public_item_photo))
        if (mListData[position].contains("mp4")) {
            holder.binding.root.findViewById<ImageView>(R.id.iv_stop).visibility = View.VISIBLE
        }
    }
}